package com.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.dao.Dao;
import com.mod.Car;
import com.mod.Product;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class GwAction extends ActionSupport{
	private Map<String, Object> session;
	private int pid;
	
	public String execute(){
		session = ActionContext.getContext().getSession();
		List<Product> car =(List<Product>) session.get("car");
		System.out.println(pid);
		if(car==null){
			car = new ArrayList<Product>();
		}
		Dao dao = new Dao();
		Product product = dao.car(pid);
		car.add(product);
		dao.save(new Car(product.getPname(),product.getPnum(),product.getPprice()));
		session.put("car", car);
		return "success";
		
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	
	

}
